home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / satellit / pacdoc / alogdisp.c < prev    next >
Text File  |  1991-04-15  |  18KB  |  662 lines

  1. /* program to display alog file
  2. ** Displays an ALyymmdd file.
  3. */
  4. /* Displays from FTL0 versions later than 13 March                                 */
  5. /* This program should be used for UO-14 AL files beginning with    */
  6. /* AL910403                                                                                                             */
  7. /*------------------------------------------------------------------------
  8.     JW Ward, G0/K8KA
  9.     HE Price, NK6k
  10.     15 April 1991
  11. ------------------------------------------------------------------------*/
  12.  
  13. #include "alog.h"
  14.  
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <time.h>
  18. #include <stdlib.h>
  19.  
  20. char buffer[40];
  21. struct ALOG_1F *alog_1f;
  22. struct ALOG_2F *alog_2f;
  23.  
  24. struct tm *utc;
  25.  
  26. struct CODE_MESSAGE {
  27.     int code;
  28.     char * message;
  29. };
  30.  
  31. /* PROTOTYPES */
  32. void main(int  argc,char  * *argv);
  33. void pcallsession(void);
  34. void pcalla(void);
  35. void pcall(void);
  36. char  *search_for_str(struct  CODE_MESSAGE *code_array,int  code);
  37. char  *short_time(long  utc);
  38. int  get_alog_struct(struct  _iobuf *fp,unsigned char  *buffer);
  39. int  alog_struct_type(void);
  40. int  callmatch(char  *call);
  41. int  find_session(long  serial);
  42.  
  43. /* CAUSES FOR FTL0 SESSION TERMINATION
  44. ** Used in calls to ftl_close_session()
  45. */
  46. #define FTC_FRMR_REM 1                                                    /* Remote frame reject                 */
  47. #define FTC_FRMR_LOCAL 2                                                /* Locally generated frmr            */
  48. #define FTC_DISC_LOCAL 3                                                /* Locally requested disc            */
  49. #define FTC_DISC_REM 4                                                    /* Remote requested disc            */
  50. #define FTC_TIMEOUT 5                                                        /* AX25 timeout.                            */
  51. #define FTC_RECONNECT    6                                                    /* Client reconnected.                */
  52. #define FTC_QUIT 7                                                            /* BBS closed down.                        */
  53.  
  54. /* Reasons for closing an FTL0 session
  55. */
  56. struct CODE_MESSAGE close_reasons[] =
  57. {
  58.         { FTC_FRMR_REM,        "user FRMR"},
  59.         { FTC_FRMR_LOCAL,    "server FRMR"},
  60.         { FTC_DISC_LOCAL,    "server disconnect"},
  61.         { FTC_DISC_REM,        "user disconnect"},
  62.         { FTC_TIMEOUT,        "FTL0 timeout"},
  63.         { FTC_RECONNECT,    "reconnection"},
  64.         { FTC_QUIT,                "quit"},
  65.         { 0,                             "Undefined error"}
  66. };
  67.  
  68. struct CODE_MESSAGE disc_reasons[] =
  69. {
  70.         { DC_TIMEOUT,            "Inactivity timeout"},
  71.         { DC_IN_ULOK,            "Unexpected input (uplink command)"},
  72.         { DC_IN_DLOK,            "Unexpected input (downlink command)"},
  73.         { DC_IN_ULRX,            "Unexpected input (uplink data)"},
  74.         { DC_IN_DLEND,        "Unexpected input (downlink end)"},
  75.         { DC_UNKNOWN_PKT,    "FTL0 packet type unknown."},
  76.         { DC_PKT_TOO_BIG,    "FTL0 command packet too long."},
  77.         { 0,                             "Undefined error"}
  78. };
  79. /* General FTL0 error messages
  80. */
  81. struct CODE_MESSAGE ftl0_errors[]={
  82. 1,    "e:PG command bug",
  83. 2,    "e:cannot continue",
  84. 3,    "e:PACSAT err",
  85. 4,    "e:No such file",
  86. 5,    "e:Selection empty",
  87. 6,    "e:Mandatory PFH err",
  88. 7,    "e:PHF err",
  89. 8,    "e:Bad selection",
  90. 9,    "e:File locked",
  91. 10,    "e:No such destination",
  92. 11,    "e:File partial.",
  93. 12,    "e:File complete.",
  94. 13,    "e:PACSAT file system full",
  95. 14,    "e:PFH err",
  96. 15,    "e:PFH checksum failure",
  97. 16,    "e:body checksum failure",
  98. 0,    ""
  99. };
  100.  
  101. /* Events logged in the ALOG, in numerical order of their event code,
  102. ** beginning with event 0 (nothing).
  103. */
  104. char *event_text[] = {
  105.     " ",
  106.     "STARTUP",
  107.     "SHUTDOWN",
  108.     "LOGIN",
  109.     "LOGOUT",
  110.     "BLOWOFF",
  111.     "REFUSED",
  112.     "BCST ON",
  113.     "BCST OFF",
  114.     "FREE DISK",
  115.     "DELETE",
  116.     "DOWNLOAD",
  117.     "UPLOAD",
  118.     "SHUT",
  119.     "OPEN",
  120.     "DIR",
  121.     "SELECT",
  122.     "ADEL OK",
  123.     "ADEL FAIL",
  124.     "DL DONE",
  125.     "UL DONE",
  126.     "DIR DONE",
  127.     "SEL DONE",
  128.     };
  129.  
  130.  
  131. #define MAX_SESSION 20
  132. /* keep last MAX_SESSION sessions, for printing callsign */
  133. struct {
  134.     unsigned char call[6];
  135.     unsigned char ssid;
  136.     int session;
  137.     } session[MAX_SESSION];
  138.  
  139. int sidx=0;
  140.  
  141.     
  142. #define msmin  (long) (60l)
  143. #define mshour (long) (60l * 60l)
  144. #define msday  (long) (60l * 60l *24l)
  145.  
  146. void main(int argc,char *argv[])
  147. {
  148.     FILE * fp;
  149.     int first = 1;
  150.     char * err_str;
  151.     int err;
  152.     int day, hour, min, sec;
  153.     long tmpl;
  154.     char tmptxt1[25];
  155.  
  156.     /* Effectively unions with the input buffer */
  157.     alog_1f = (struct ALOG_1F *) buffer;
  158.     alog_2f = (struct ALOG_2F *) buffer;
  159.  
  160.     if (argc<2) {
  161.         printf("usage: alogdisp logfile [callsign]\n");
  162.         exit(1);
  163.     }
  164.  
  165.     if ((fp = fopen(argv[1], "rb")) == NULL){
  166.         printf("cannot open: %s\n",argv[1]);
  167.         exit(2);
  168.     }
  169.  
  170.     while (1) {
  171.  
  172.         err = get_alog_struct(fp, buffer);
  173.         if (err){
  174.             if (err!=1)
  175.                 printf("Activity log file is damaged.\n");
  176.             fclose(fp);
  177.             break;
  178.         }
  179.         
  180.         if ( (argc>2) && !callmatch(argv[2]) )
  181.             continue;
  182.  
  183.         /* Print the header once per log file */
  184.         if (first){
  185.             printf("FTL0 Activity Log for %s", asctime(gmtime(&alog_1f->tstamp)));
  186.             printf("\n");
  187.             printf("Time      Activity   Call      Rx Session\n"  );
  188.             first = 0;
  189.         }
  190.  
  191.         if (alog_1f->var3 != 0L)
  192.             err_str = search_for_str(ftl0_errors, (int) alog_1f->var3);
  193.         else
  194.             err_str = "";
  195.  
  196.         switch(alog_1f->event) {
  197.         case ALOG_FTL0_STARTUP:
  198.             /* FTL0 BBS code executed */
  199.             printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  200.         break;
  201.  
  202.         case ALOG_FTL0_SHUTDOWN:
  203.             /* FTL0 BBS task exits. */
  204.             printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  205.         break;
  206.         
  207.         case ALOG_BBS_SHUT:
  208.             /* Ground command shuts bbs */
  209.             pcalla();
  210.         break;
  211.  
  212.         case ALOG_BBS_OPEN:
  213.             /* Ground command opens bbs */
  214.             pcalla();
  215.         break;
  216.  
  217.         case ALOG_BCAST_START:
  218.             /* User starts a broadcast
  219.                  var1 = file number
  220.                  var2 = number of seconds for broadcast
  221.                  var3 = error
  222.                  var4 = length of data packets
  223.             */
  224.             pcalla();
  225.             if (alog_2f->var3 != 0L)
  226.                 err_str = search_for_str(ftl0_errors, (int) alog_2f->var3);
  227.             else
  228.                 err_str = "";
  229.             printf("        f#%lx dur:%lu l:%ld %s",alog_2f->var1,
  230.                 alog_2f->var2,alog_2f->var4,err_str);
  231.         break;
  232.  
  233.         case ALOG_BCAST_STOP:
  234.             /* User stops a broadcast
  235.                  var1 = file number
  236.                  var2 = unused
  237.                  var3 = error
  238.             */
  239.             pcalla();
  240.             if (alog_2f->var3 != 0L)
  241.                 err_str = search_for_str(ftl0_errors, (int) alog_2f->var3);
  242.             else
  243.                 err_str = "";
  244.             printf("        f#%lx  %s",alog_2f->var1,err_str);
  245.         break;
  246.  
  247.         case ALOG_DISKSPACE:
  248.             /* Diskspace is logged hourly
  249.                  var1 = number of disk clusters free (1008 bytes of data each)
  250.                  var2 = number of directory entries free
  251.             */
  252.             printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  253.             printf("                     %ld bytes \\",alog_1f->var1*1008l);
  254.             printf(" %ld dirs",alog_1f->var2);
  255.         break;
  256.  
  257.         case ALOG_FILE_DELETE:
  258.             /* Command station deletes file
  259.                  var1 = file number
  260.                  var2 = unused
  261.                  var3 = error code
  262.             */
  263.             pcalla();
  264.             if (alog_1f->var3 != 0L)
  265.                 err_str = search_for_str(ftl0_errors, (int) alog_1f->var3);
  266.             else
  267.                 err_str = "";
  268.             printf("        f#%lx",alog_1f->var1);
  269.         break;
  270.  
  271.         case ALOG_USER_REFUSED:
  272.             printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  273.             /* BBS was full.
  274.             */
  275.         break;
  276.  
  277.         case ALOG_START_SESSION :
  278.             /* User logs on. This is the only time we get callsign
  279.                  information for connected mode users; must use serial_no
  280.                  from now on.
  281.             */
  282.             pcallsession();
  283.             printf(" %06u",alog_1f->serial_no);
  284.         break;
  285.  
  286.         case ALOG_CLOSE_SESSION :
  287.             /* Server closes session.
  288.                 var1 = reason for closing session, see close_reasons array.
  289.                 var2 = bytes downloaded, if download in progress
  290.                 var3 = bytes uploaded, if upload in progress
  291.                 var2 and var3 are 0 if no transfer in progress.
  292.                 download includes directory commands.
  293.             */
  294.             pcall();
  295.             printf(" %06u",alog_1f->serial_no);
  296.             printf(" %s  ", search_for_str(close_reasons, (int) alog_1f->var1));
  297.             if (alog_1f->var2)
  298.                 printf("\n%41.41s Incomplete D/L @ %lu bytes", "",alog_1f->var2);
  299.             if (alog_1f->var3)
  300.                 printf("\n%41.41s Incomplete U/L @ %lu bytes","", alog_1f->var3);
  301.         break;
  302.  
  303.         case ALOG_DISCONNECT :
  304.             /* Server is disconnecting user.
  305.                  var1 = reason for disconnect, see disc_reasons array.
  306.             */
  307.             pcall();
  308.             printf(" %s  ", search_for_str(disc_reasons, (int) alog_1f->var1));
  309.         break;
  310.         
  311.  
  312.         case ALOG_FILE_DOWNLOAD:
  313.             /* Server receives download command.
  314.                  var1 = file number
  315.                  var2 = continue offset
  316.                  var3 = error code
  317.                  var4 = flag indicating that download was from select list.
  318.             */
  319.             pcall();
  320.             if (alog_1f->var3 != 0L)
  321.                 err_str = search_for_str(ftl0_errors, (int) alog_1f->var3);
  322.             else
  323.                 err_str = "";
  324.             printf("        f#%lx off:%lu %s",alog_1f->var1,
  325.                 alog_1f->var2,err_str);
  326.             if (alog_1f->var4)
  327.                 printf("(selected)");
  328.         break;
  329.  
  330.         case ALOG_END_DOWNLOAD:
  331.             /* User has indicated end of download to server. May be good or bad.
  332.                  var1 = number of bytes downloaded. Not necessarily file length,
  333.                         if this was a continued download.
  334.                  var2 = FTL_DL_ACK_CMD if user acked.
  335.                         FTL_DL_NAK_CMD if user n'acked.
  336.                  User may n'ack if checksum fails.
  337.             */
  338.             pcall();
  339.             printf("        %ld bytes ",alog_1f->var1);
  340.             if ((unsigned char) alog_1f->var2 == 0x0c)
  341.                 printf("Ack'd");
  342.             else
  343.                 printf("Nak'd");
  344.         break;
  345.  
  346.         case ALOG_FILE_UPLOAD:
  347.             /* Server receives client's upload command.
  348.                  var1 = file number
  349.                  var2 = continue offset
  350.                  var3 = error code
  351.                  var4 = file length as told by client to server.
  352.             */
  353.             pcall();
  354.             if (alog_1f->var3 != 0L)
  355.                 err_str = search_for_str(ftl0_errors, (int) alog_1f->var3);
  356.             else
  357.                 err_str = "";
  358.             printf("        f#%lx off:%lu l#%lu %s",alog_1f->var1,
  359.                 alog_1f->var2,alog_1f->var4,err_str);
  360.         break;
  361.  
  362.         case ALOG_END_UPLOAD:
  363.             /* Server has received, and finished checksumming, the file.
  364.                  var1 = time checksum started. Subtractr from alog_1f->time
  365.                         to figure out how many seconds to checksum the file.
  366.                  var2 = error code.
  367.                  var3 = number of bytes uploaded; not necessarily same as file size,
  368.                         since this might be a continued upload.
  369.             */
  370.             pcall();
  371.             printf("        %ld bytes %ld seconds cksum",alog_1f->var3,
  372.                 alog_1f->tstamp - alog_1f->var1);
  373.             if (alog_1f->var2)
  374.                 printf(" Nak'd");
  375.         break;
  376.  
  377.         case ALOG_DIR:
  378.             /* Server receives directory request from client.
  379.                  var1 = file number (0xffffffff or 0 indicate dir from selection.)
  380.                  var2 = error code.
  381.             */
  382.             pcall();
  383.             if (alog_1f->var2 != 0L)
  384.                 err_str = search_for_str(ftl0_errors, (int) alog_1f->var2);
  385.             else
  386.                 err_str = "";
  387.             if ((alog_1f->var1 != 0xffffffff) && (alog_1f->var1 != 0L))
  388.                 printf("        f#%lx  %s",alog_1f->var1,err_str);
  389.             else
  390.                 printf("        from selection.");
  391.         break;
  392.  
  393.         case ALOG_END_DIR:
  394.             /* Server sends last packet of directory to client.
  395.                  var1 = total number of bytes in directory.
  396.           */
  397.                 pcall();
  398.                 printf("        %ld bytes",alog_1f->var1);
  399.         break;
  400.  
  401.             /* Automatic file removal
  402.                  var1 = file number
  403.                  var2 = free directory entries in system
  404.                  var3 = free file clusters in system
  405.                  var4 = expiry time (earliest at which file could be deleted)
  406.             */
  407.         case ALOG_FILE_REMOVED:
  408.             printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  409.             printf("        f#%lx (exp: (%lx) %23.23s)",alog_1f->var1,alog_1f->var4,
  410.                 asctime(gmtime(&(alog_1f->var4))) );
  411.         break;
  412.  
  413.         case ALOG_SELECT:
  414.         /* Select command received by server. No vars used */
  415.             pcall();
  416.         break;
  417.  
  418.         case ALOG_SELECT_DONE:
  419.         /* Finished building select list
  420.              var1 = length of user's selection equation
  421.              var2 = oldest file considered for the selection
  422.              var3 = newest file considered for the selection
  423.              var4 = number of files selected
  424.         */
  425.             pcall();
  426.             if (alog_1f->var2 == 0x131d1741) 
  427.                 strcpy(tmptxt1,"start");
  428.             else {
  429.                 /* compute time before "now" */
  430.                 tmpl = alog_1f->tstamp - alog_1f->var2;
  431.                 if (tmpl < 0)
  432.                     strcpy(tmptxt1,"future?");
  433.                 else {
  434.                     day = tmpl/msday;
  435.                     tmpl= tmpl % msday;
  436.                     hour = tmpl/mshour;
  437.                     tmpl = tmpl % mshour;
  438.                     min = tmpl/msmin;
  439.                     tmpl = tmpl % msmin;
  440.                     sec = tmpl;
  441.                     sprintf(tmptxt1,"%03u/%02u:%02u:%02u",
  442.                         day,hour,min,sec);
  443.                 }
  444.             }
  445.             printf("        %s len:%ld selected:%ld",
  446.                 tmptxt1, alog_1f->var1, alog_1f->var4);
  447.         break;
  448.  
  449.         default:
  450.             printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  451.             printf("Unknown (%d)", alog_1f->event);
  452.         break;
  453.         }
  454.         printf("\n");
  455.     }
  456. }
  457.  
  458. /*------------------------------------------------------------------------
  459.  Prints callsign for the beginning of a session, and puts the
  460.  call and ssid into the structure array holding each session.
  461. ------------------------------------------------------------------------*/
  462. void pcallsession(void)
  463. {
  464.     memcpy(session[sidx].call,alog_2f->call,6);
  465.     session[sidx].ssid = alog_2f->ssid;
  466.     session[sidx].ssid = alog_2f->ssid;
  467.     session[sidx].session = alog_2f->serial_no;
  468.  
  469.     /* Move circularly through session array. */
  470.     sidx = (sidx+1)%MAX_SESSION;
  471.  
  472.     printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  473.     printf("%6.6s-%-2u  %u ",alog_2f->call,alog_2f->ssid,alog_2f->rxchan);
  474.  
  475. }
  476.  
  477. /*------------------------------------------------------------------------
  478.   Prints callsign for action not related to a connected session.
  479.     Takes call, ssid and receiver out of current alog_2f structure.
  480. ------------------------------------------------------------------------*/
  481. void pcalla(void)
  482. {
  483.     printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  484.     printf("%6.6s-%-2u  %u ",alog_2f->call,alog_2f->ssid,alog_2f->rxchan); 
  485. }
  486.  
  487. /*------------------------------------------------------------------------
  488.   Prints callsign for action within a connected session.
  489.     Looks up correct session in session[] using serial_no from current
  490.     alog_1f structure.
  491.     Takes call and ssid out of session[].
  492. ------------------------------------------------------------------------*/
  493. void pcall(void)
  494. {
  495.     int i;
  496.     /* Find the session looking up serial numbers */
  497.     for (i=0;i<MAX_SESSION;i++)
  498.         if (session[i].session == alog_1f->serial_no)
  499.             break;
  500.  
  501.     /* Found it */
  502.     printf("%s  %-9.9s  ",short_time(alog_1f->tstamp), event_text[alog_1f->event]);
  503.     if (i < MAX_SESSION) 
  504.         printf("%6.6s-%-2u    ",session[i].call,session[i].ssid);
  505.     else
  506.         printf("******-**    "); 
  507. }
  508.  
  509. char * search_for_str(struct CODE_MESSAGE code_array[], int code){
  510.     int i=0;
  511.     if (code==-1) return("Can't add");
  512.     while ( (code_array[i].code != code) && (code_array[i].code) )
  513.         ++i;
  514.     return(code_array[i].message);
  515. }
  516.  
  517. /*------------------------------------------------------------------------
  518.     provide an HH:MM:SS timestamp.
  519. ------------------------------------------------------------------------*/
  520. char time_stamp[9];
  521. char * short_time(time_t utc){
  522.     struct tm * tp;
  523.     tp = gmtime(&utc);
  524.     sprintf(time_stamp, "%02d:%02d:%02d", tp->tm_hour, tp->tm_min, tp->tm_sec);
  525.     return time_stamp;
  526. }
  527.     
  528.  
  529. /*------------------------------------------------------------------------
  530.     Read a variable length record from the file.
  531.     The first byte is always record type.
  532.     The second byte is always record length.
  533.     See alog.h for further details of the two variable length structs
  534.     which can be in the file.
  535. ------------------------------------------------------------------------*/
  536. int get_alog_struct(FILE * fp, unsigned char * buffer){
  537.     int cnt;
  538.     int error = 0;
  539.  
  540.     /* First two bytes contain structure length */
  541.     cnt = fread(buffer,1, 2, fp);
  542.     if (cnt != 2){
  543.         error = 1;
  544.     }
  545.     
  546.     /* Alog structure never greater then 40 bytes */
  547.     else if (alog_1f->len >40) {
  548.         printf("File is damaged\n");
  549.         error = 2;
  550.     }
  551.  
  552.     else{
  553.         /* Get the rest of the structure, now length is known */
  554.         cnt = fread(buffer+2, 1, alog_1f->len-2, fp);
  555.         if (cnt+2 != alog_1f->len) {
  556.             printf("File is damaged\n");
  557.             error = 3;
  558.         }
  559.     }
  560.     return error;
  561. }
  562. /*------------------------------------------------------------------------
  563.     Checks the type of record in the global alog structure and returns
  564.     an appropriate integer. Generally, this tells if the record type is
  565.     alog1 or alog2, though some other divisions have been introduced.
  566.     
  567.     START_SESSION MUST RETURN 2
  568.     CONNECTED MODE OPERATIONS MUST RETURN 1
  569.     ADMINISTRATIVE OPERATIONS MUST RETURN 0
  570. ------------------------------------------------------------------------*/
  571. int alog_struct_type(void){
  572.  
  573.     int type;
  574.  
  575.     switch(alog_1f->event){
  576.  
  577.         /* All of these have callsigns in them */
  578.         case ALOG_START_SESSION:
  579.         case ALOG_BCAST_START:
  580.         case ALOG_BCAST_STOP:
  581.         case ALOG_FILE_DELETE:
  582.         case ALOG_BBS_SHUT:
  583.         case ALOG_BBS_OPEN:
  584.             type = 2;
  585.         break;
  586.  
  587.         /* These don't have or refer to callsigns. This is the */
  588.         /* group containing all automatic s/c generated events.*/
  589.         case ALOG_FTL0_STARTUP:
  590.         case ALOG_FTL0_SHUTDOWN:
  591.         case ALOG_DISKSPACE:
  592.         case ALOG_FILE_REMOVED:
  593.         case ALOG_FILE_NOT_REMOVED:
  594.             type = 0;
  595.         break;
  596.  
  597.         /* All connected mode events */
  598.         case ALOG_CLOSE_SESSION:
  599.         case ALOG_DISCONNECT:
  600.         case ALOG_FILE_DOWNLOAD:
  601.         case ALOG_FILE_UPLOAD:
  602.         case ALOG_DIR:
  603.         case ALOG_SELECT:
  604.         case ALOG_END_DOWNLOAD:
  605.         case ALOG_END_UPLOAD:
  606.         case ALOG_END_DIR:
  607.         case ALOG_SELECT_DONE:
  608.             type = 1;
  609.         break;
  610.  
  611.         /* Put refusals in a class by themselves, because they are anoying */
  612.         case ALOG_USER_REFUSED:
  613.             type = 4;
  614.         break;
  615.  
  616.         default:
  617.             type = 3;
  618.         break;
  619.  
  620.     }
  621.     return type;
  622. }
  623.  
  624.  
  625. /*------------------------------------------------------------------------
  626.     Return 1 if current alog record refers to the offered callsign.
  627.  
  628.     Special callsign "admin" will return true on all type 0, administrative
  629.     log records.
  630. ------------------------------------------------------------------------*/
  631. int callmatch(char * call){
  632.     int type;
  633.     int retval = 0;
  634.     int i;
  635.     type = alog_struct_type();
  636.     if (type == 1){
  637.         i = find_session(alog_1f->serial_no);
  638.         if ( (i >= 0) && (!strnicmp(session[i].call, call,6)))
  639.             retval = 1;
  640.     }
  641.     else if ( (type == 2) && (!strnicmp(alog_2f->call, call,6)) )
  642.         retval = 1;
  643.     else if ( (type == 0) && !stricmp(call, "ADMIN") )
  644.         retval = 1;
  645.  
  646.     return retval;
  647. }
  648.  
  649. /*------------------------------------------------------------------------
  650.     look up serial in the session[] array. Return -1 if not found.
  651. ------------------------------------------------------------------------*/
  652. int find_session(long serial){
  653.     int i;
  654.     for (i=0;i<MAX_SESSION;i++)
  655.         if (session[i].session == serial)
  656.             break;
  657.     if (i < MAX_SESSION)
  658.         return i;
  659.     else
  660.         return -1;
  661. }
  662.